package bizlogic;
import java.util.ArrayList;

import model.BookingDTO;
import model.BookingSearchDTO;
import dao.DAOException;
import dao.DAOFactory;
import dao.BookingDAO;
import dao.mysql.BookingDAOImpl;

public class BookingManager {
	private BookingDAO bookingDAO;
	public BookingManager() {
		bookingDAO = DAOFactory.loadInstance().getBookingDAO();
	}
	@SuppressWarnings("finally")
	public ArrayList<BookingDTO> findBookingsByCriteria(BookingSearchDTO bso){
		ArrayList<BookingDTO> currentList = new ArrayList<BookingDTO>();
		try {
			currentList = bookingDAO.findBookingByCriteria(bso);
		} catch (DAOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally
		{
			return currentList;//aa
		}
		
	}
	@SuppressWarnings("finally")
	public BookingDTO findBooking(String id){
		BookingDTO currentBooking = new BookingDTO();
		try {
			currentBooking = bookingDAO.findBooking(id);
		} catch (DAOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally
		{
			return currentBooking;//lll
		}
		
	}
    @SuppressWarnings("finally")
	public ArrayList<BookingDTO> getAllBooking() {
    	ArrayList<BookingDTO> currentList = new ArrayList<BookingDTO>();
		try {
			currentList = bookingDAO.getAllBooking();
		} catch (DAOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally
		{
			return currentList;
		}
    }
    public void insertBooking(BookingDTO booking) {
    	try {
			bookingDAO.insertBooking(booking);
		} catch (DAOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    }
    public void updateBooking(BookingDTO booking) {
    	try {
			bookingDAO.updateBooking(booking);
		} catch (DAOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    }
    public void deleteBooking(String id) {
    	try {
			bookingDAO.deleteBooking(id);
  
		} catch (DAOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    }
	

    
}
